/*
 *  WCockpitRenderer.h
 *  GLRender
 *
 *  Created by Teseo on 22.05.10.
 *  Copyright 2010 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef COCKPIT_RENDERER
#define COCKPIT_RENDERER

#include "Base.h"
#include "Texture.h"
#include <QtOpenGL>
#include "ObjReader.h"
#include "Mesh.h"

class Player;

class WCockpitRenderer {
private:
	static const int MAX_FLASH_COUNTER = 30;
	
	GLuint SQUARE_DL;
	
	
	GLuint initSquare();
	double tau, h, w;
	int flashCounter, maxFlashCounter;
	RGBd flashColor;
	
	Texture radarTexture, cockpitTexture, radarTargetTexture, arrowTexture,
	centerTexture, horizontBackgroundTexture, horizontMarkTexture, targetTexture, radarStrokeTexure,
	lifebarTexure, lifebarBackgroundTexture, airplaneProfileTexture;
	
	
	virtual
	void renderRadar(const Point3d &target);
	void renderAltimeter(const double height);
	void renderHorizontal(double alpha);
	void renderVertical(double alpha);
	void renderCockpit();
	void renderFlash(const RGBd &rgb);
	void renderTarget();
	void renderLifebar(double life, double maxLife);
	void renderTargetArrow(const Point3d &where);

public:
	WCockpitRenderer() : tau(0.0), flashCounter(0) { }
	
	virtual
	~WCockpitRenderer(){ glDeleteLists(SQUARE_DL,1);}
	
	void initialize();
	void renderPlayer(Player *player);
	void startFlash(const RGBd &rgb, const int duration);
	
	inline
	double getHeight() const { return h; }
	
	inline 
	double getWidth() const { return w; }
	
	inline 
	void setDimensions(const double w, const double h)
	{
		this->h = h; this->w = w;
	}
	
};

#endif
